<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript" src="../js/vue.js">
			
		</script>
	</head>
	<body>
		<div id="box">
			<h2>a的值：{{numbers.a}}</h2>
			<button type="button" @click='numbers.a++'>点我改变a的值</button>
			<h2>b的值：{{numbers.b}}</h2>
			<button type="button" @click='numbers.b++'>点我改变b的值</button>
		</div>
		<script type="text/javascript" charset="utf-8">
			Vue.config.productionTip=false
			const vm = new Vue({
				el: "#box",
				data: {
					numbers:{
						a:1,
						b:1
					}
				},		
				watch: {//监视多级结构中某个属性的变化
					/* 'numbers.a':{
						handler(){
							console.log('a的值改变了')
						}
					} */
					//监视多级结构中所有属性的变化
					numbers:{
						deep:true,
						handler(){
							console.log('numbers的值改变了')
						}
					}
				},
			
			})
			
		</script>
	</body>
</html>